home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_gen_moveobj.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  186 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_MoveObj.cog
  4. #
  5. #
  6. # A hack for pushing blocks around. Inspired by Reed Derleth
  7. # IMPORTANT. Make sure you attach the cog to a valid object.
  8. # Make sure that the ghostthing is assigned to a ghost object.
  9. #
  10. # Usage:
  11. # -Get behind the object (face the direction you want it to go)
  12. # -Activate once to push forward.
  13. # -Activate twice rapidly to pull. (the object will materialise on top of you just walk forward)
  14. # -You can teleport things out of the world so be careful
  15. #
  16. # [SXC]
  17. #
  18. # (C) 1998 LucasArts Entertainment Co. All Rights Reserved
  19. # ========================================================================================
  20.  
  21. symbols
  22.     message  startup
  23.     message  activate
  24.     message    timer
  25.  
  26.     vector   playervec            local
  27.     vector   dudpyrvec            local
  28.     vector   origvec              local
  29.     vector   newthingvec          local
  30.     vector   newvector            local
  31.  
  32.     template ghostthing = ghost
  33.  
  34.     thing    player0              local
  35.     thing    pushobj
  36.     thing    newposthing          local
  37.  
  38.     int      direction =     0     local
  39.     int        pullFlag =         0        local
  40.  
  41.     float    playery =         0     local
  42.     float    playerx =         0     local
  43.     float    xpos =             0     local
  44.     float    ypos =             0     local
  45.     float    zpos =             0     local
  46.     float        timeSpan=        
  47.  
  48.     sector   gensector            local
  49.  
  50. end
  51.  
  52.  
  53. # ========================================================================================
  54.  
  55. code
  56.  
  57. startup:
  58.     dudpyrvec = VectorSet(0, 0, 0);
  59.     return;
  60.  
  61. # ........................................................................................
  62.  
  63. activate:
  64.     pullFlag = pullFlag + 1;
  65.     SetTimer(timeSpan);    
  66.     playervec = GetThingLVec(player0);
  67.     playery = VectorY(playervec);
  68. //    printflex(playery);
  69.     playerx = VectorX(playervec);
  70. //    printflex(playerx);
  71.  
  72.     if ((playery > 0) &&
  73.         ((playerx > -0.7) && (playerx < 0.7))) {
  74.             direction = 1;                               //north
  75.             //print("reached 1 north");
  76.         }
  77.     else if ((playery < 0) &&
  78.               ((playerx > -0.7) && (playerx < 0.7))) {
  79.                   direction = 3;                          //south
  80.                  //print("reached 2 south");
  81.               }
  82.     else if ((playerx > 0) &&
  83.               ((playery > -0.7) && (playery < 0.7))) {
  84.                   direction = 2;                          //east
  85.                   //print("reached 3 east");
  86.               }
  87.     else if ((playerx < 0) &&
  88.               ((playery > -0.7) && (playery < 0.7))) {
  89.                   direction = 4;                          //west
  90.                   //print("reached 4 west");
  91.     }
  92.  
  93.     //print("direction is");
  94.     //printint(direction);
  95.     pushobj = GetSenderRef();                          //get vectors
  96.     origvec = GetThingPos(pushobj);
  97.     gensector = GetThingSector(pushobj);
  98.  
  99.     xpos = VectorX(origvec);                           //get positions
  100.     //printflex(xpos);
  101.     ypos = Vectory(origvec);
  102.     //printflex(ypos);
  103.     zpos = Vectorz(origvec);
  104.     //printflex(zpos);
  105.  
  106.     return;
  107.  
  108.     # .....................................................................................
  109.  
  110.     timer:
  111.  
  112.         //print("reached timer");
  113.         if (pullFlag == 2)
  114.         {
  115.             if (direction == 1)
  116.          {
  117.              ypos = ypos - 0.2;
  118.              //print("move South");
  119.              //printint(ypos);
  120.          }
  121.          else if (direction == 2)
  122.        {
  123.              xpos = xpos - 0.2;
  124.              //print("move West");
  125.              //printint(xpos);
  126.          }
  127.          else if (direction == 3)
  128.        {
  129.           ypos = ypos + 0.2;
  130.              //print("move North");
  131.              //printint(xpos);          
  132.          }
  133.          else if (direction == 4)
  134.        {
  135.           xpos = xpos + 0.2;
  136.              //print("move East");
  137.              //printint(ypos);            
  138.          }    
  139.         }
  140.         else if (pullFlag == 1)
  141.         {
  142.             if (direction == 1)
  143.             {
  144.                 ypos = ypos + 0.2;
  145.                //print("move North");
  146.                 //printint(xpos);
  147.             }
  148.             else if (direction == 2)
  149.          {
  150.                 xpos = xpos + 0.2;
  151.                 //print("move East");
  152.                 //printint(ypos);
  153.             }
  154.             else if (direction == 3)
  155.          {
  156.                 ypos = ypos - 0.2;
  157.                 //print("move South");
  158.                 //printint(ypos);
  159.             }
  160.             else if (direction == 4)
  161.          {
  162.                 xpos = xpos - 0.2;
  163.                 //print("move West");
  164.                 //printint(xpos);
  165.             }
  166.       }
  167.     direction = 0;
  168.     pullFlag = 0;
  169.     newvector = VectorSet(xpos, ypos, zpos);
  170.     newposthing = CreateThingAtPos(ghostthing, gensector, newvector, dudpyrvec);
  171.     TeleportThing(pushobj, newposthing);
  172.     DestroyThing(newposthing);
  173.  
  174.     return;
  175.  
  176.     end
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.